home *** CD-ROM | disk | FTP | other *** search
- #ifndef lint
- static char SccsId[]= "@(#)cpit_main.c V1.7 3/15/95";
- #endif
-
- /*------------------------------------------------------------------
- | file name -- cpit_main.c
- |-----------------------------------------------------------------*/
-
- #include "std.h"
- #include "dvstd.h"
- #include "dvtools.h"
- #include "Tfundecl.h"
- #include "VOfundecl.h"
- #include "VUerfundecl.h"
- #include "GRfundecl.h"
- #include "cpit_vars.h"
- #include "cpit_fundecl.h"
- #include "MISCfuns.h"
-
- #ifdef WINNT
- #include <windows.h>
- #endif /* WINNT */
-
-
- #ifndef WINNT
-
- /* Include the X based files so we can add AppTimeOuts */
- #ifdef CONST
- #undef CONST
- #endif
-
- #ifndef __STDC__
- #define _NO_PROTO
- #endif
-
- /* X11 include files */
- #include <X11/Xlib.h>
- #include <X11/Intrinsic.h>
-
- #endif /* Not WINNT */
-
-
- /* This program can be linked to run:
- |
- | With 100% CPU usage (which shows updates in a tight loop)
- | comment #define DV_USE_TIMER
- | With Time-Outs (which show update based on a timer).
- | uncomment #define DV_USE_TIMER
- */
- #define DV_USE_TIMER
-
- #ifdef DV_USE_TIMER
-
- LOCAL INT TimeoutInterval = 10;
-
- #ifdef WINNT
-
- LOCAL HWND Hwnd;
- LOCAL VOID CALLBACK TimeOutProc V_P_((HWND hwnd,
- UINT uMsg,
- UINT idEvent,
- DWORD dwTime));
-
- #else /* UNIX */
-
- LOCAL XtAppContext app_context;
- LOCAL void UpdateProc V_P_((ADDRESS args, XtIntervalId *interval_id));
-
- #endif /* WINNT */
- #endif /* DV_USE_TIMER */
-
-
-
-
- #define SEARCH_PATH (CHAR*)NULL
- #define DISPFORM_TABLE (CHAR*)NULL
-
-
- /*--------------------------------------------------------------------
- | main()
- | This module is the basic skeleton of a DataViews application.
- |
- */
-
- #ifdef WINNT
- int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
- LPSTR lpCmdLine, int nCmdShow )
- {
- CHAR *device = NULL;
- INT argc;
- CHAR **argv;
-
- make_argv(&argc,&argv,GetCommandLine());
-
- #else /* Not WINNT */
- int
- main (argc, argv)
- int argc;
- char *argv[];
- {
- CHAR *device = NULL;
-
- #endif /* WINNT */
-
-
- /* Initialize arguments, argv[1] - device name */
- if (argc > 1)
- device = argv[1];
-
- /* Initialize */
- /* DataViews Initializaton */
- (VOID) TInit (SEARCH_PATH, DISPFORM_TABLE);
-
- InitDisplays (device); /* found in cpit_dsp.c */
-
- #ifdef DV_USE_TIMER
- #ifdef WINNT
- /* Get the Windows based information */
- (VOID) GRget (V_WIN32_WINDOW_HANDLE, &Hwnd, V_END_OF_LIST);
-
- /* Post a timeout for dynamic updates
- | The timeout procedure will update the dynamics of
- | all screens which have been opened. The procedure is invoked
- | whenever the specified time interval elapses. The interval is
- | specified in milliseconds.
- */
- SetTimer (Hwnd, (UINT)Hwnd, TimeoutInterval, (TIMERPROC)TimeOutProc);
- #else
- /* Extract the X information so we can setup a Time-Out Proc
- | for updating....
- | Get the Xt Application Context information.
- | Post a timeout procedure will update the dynamics of
- | all screens which have been opened. The procedure is invoked
- | whenever the specified time interval elapses. The interval is
- | specified in milliseconds.
- */
- (VOID) GRget (V_X_APPLIC_CONTEXT, &app_context, V_END_OF_LIST);
- XtAppAddTimeOut (app_context, TimeoutInterval,
- (XtTimerCallbackProc) UpdateProc, NULL);
-
- #endif /* WINNT */
- #endif /* DV_USE_TIMER */
-
-
- /* Control Loop */
- ApplicationState = (DV_BOOL) RUNNING;
- while (ApplicationState == RUNNING)
- {
- /* Gather and Process User Inputs
- | Note: since we posted a time-out, the event
- | handler will call our function to handle
- | the updating of dynamic objects.
- */
-
- /* Gather and Process User Inputs */
- HandleEvents (); /* found in cpit_event.c */
-
- }
-
- /* Termination and Clean Up */
- TermDisplays (); /* found in cpit_dsp.c */
-
- (VOID) TTerminate (); /* DataViews Termination */
- return 1;
- }
-
- #ifdef DV_USE_TIMER
- #ifdef WINNT
-
- /*ARGSUSED*/
- LOCAL VOID CALLBACK
- TimeOutProc (hwnd, uMsg, idEvent, dwTime)
- HWND hwnd;
- UINT uMsg;
- UINT idEvent;
- DWORD dwTime;
- {
- HandleDynamics ();
- }
-
- #else
- /*ARGSUSED*/
- LOCAL void
- UpdateProc (args, interval_id)
- ADDRESS args;
- XtIntervalId *interval_id;
- {
-
- /* Update the current View */
- HandleDynamics ();
-
- /* Re-Post the Time-Out */
- XtAppAddTimeOut (app_context, TimeoutInterval,
- (XtTimerCallbackProc) UpdateProc, NULL);
- }
- #endif /* WINNT */
- #endif /* DV_USE_TIMER */
-